/*
	Copyright (c) 2004-2009, The Dojo Foundation All Rights Reserved.
	Available via Academic Free License >= 2.1 OR the modified BSD license.
	see: http://dojotoolkit.org/license for details
*/


if(!dojo._hasResource["dijit._Widget"]){
dojo._hasResource["dijit._Widget"]=true;
dojo.provide("dijit._Widget");
dojo.require("dijit._base");
dojo.connect(dojo,"_connect",function(_1,_2){
if(_1&&dojo.isFunction(_1._onConnect)){
_1._onConnect(_2);
}
});
dijit._connectOnUseEventHandler=function(_3){
};
dijit._lastKeyDownNode=null;
if(dojo.isIE){
dojo.doc.attachEvent("onkeydown",function(_4){
dijit._lastKeyDownNode=_4.srcElement;
});
}else{
dojo.doc.addEventListener("keydown",function(_5){
dijit._lastKeyDownNode=_5.target;
},true);
}
(function(){
var _6={},_7=function(dc){
if(!_6[dc]){
var r=[],_8,_9=dojo.getObject(dc).prototype;
for(var _a in _9){
if(dojo.isFunction(_9[_a])&&(_8=_a.match(/^_set([a-zA-Z]*)Attr$/))&&_8[1]){
r.push(_8[1].charAt(0).toLowerCase()+_8[1].substr(1));
}
}
_6[dc]=r;
}
return _6[dc]||[];
};
dojo.declare("dijit._Widget",null,{id:"",lang:"",dir:"","class":"",style:"",title:"",tooltip:"",srcNodeRef:null,domNode:null,containerNode:null,attributeMap:{id:"",dir:"",lang:"","class":"",style:"",title:""},_deferredConnects:{onClick:"",onDblClick:"",onKeyDown:"",onKeyPress:"",onKeyUp:"",onMouseMove:"",onMouseDown:"",onMouseOut:"",onMouseOver:"",onMouseLeave:"",onMouseEnter:"",onMouseUp:""},onClick:dijit._connectOnUseEventHandler,onDblClick:dijit._connectOnUseEventHandler,onKeyDown:dijit._connectOnUseEventHandler,onKeyPress:dijit._connectOnUseEventHandler,onKeyUp:dijit._connectOnUseEventHandler,onMouseDown:dijit._connectOnUseEventHandler,onMouseMove:dijit._connectOnUseEventHandler,onMouseOut:dijit._connectOnUseEventHandler,onMouseOver:dijit._connectOnUseEventHandler,onMouseLeave:dijit._connectOnUseEventHandler,onMouseEnter:dijit._connectOnUseEventHandler,onMouseUp:dijit._connectOnUseEventHandler,_blankGif:(dojo.config.blankGif||dojo.moduleUrl("dojo","resources/blank.gif")).toString(),postscript:function(_b,_c){
this.create(_b,_c);
},create:function(_d,_e){
this.srcNodeRef=dojo.byId(_e);
this._connects=[];
this._subscribes=[];
this._deferredConnects=dojo.clone(this._deferredConnects);
for(var _f in this.attributeMap){
delete this._deferredConnects[_f];
}
for(_f in this._deferredConnects){
if(this[_f]!==dijit._connectOnUseEventHandler){
delete this._deferredConnects[_f];
}
}
if(this.srcNodeRef&&(typeof this.srcNodeRef.id=="string")){
this.id=this.srcNodeRef.id;
}
if(_d){
this.params=_d;
dojo.mixin(this,_d);
}
this.postMixInProperties();
if(!this.id){
this.id=dijit.getUniqueId(this.declaredClass.replace(/\./g,"_"));
}
dijit.registry.add(this);
this.buildRendering();
if(this.domNode){
this._applyAttributes();
var _10=this.srcNodeRef;
if(_10&&_10.parentNode){
_10.parentNode.replaceChild(this.domNode,_10);
}
for(_f in this.params){
this._onConnect(_f);
}
}
if(this.domNode){
this.domNode.setAttribute("widgetId",this.id);
}
this.postCreate();
if(this.srcNodeRef&&!this.srcNodeRef.parentNode){
delete this.srcNodeRef;
}
this._created=true;
},_applyAttributes:function(){
var _11=function(_12,_13){
if((_13.params&&_12 in _13.params)||_13[_12]){
_13.attr(_12,_13[_12]);
}
};
for(var _14 in this.attributeMap){
_11(_14,this);
}
dojo.forEach(_7(this.declaredClass),function(a){
if(!(a in this.attributeMap)){
_11(a,this);
}
},this);
},postMixInProperties:function(){
},buildRendering:function(){
this.domNode=this.srcNodeRef||dojo.create("div");
},postCreate:function(){
},startup:function(){
this._started=true;
},destroyRecursive:function(_15){
this._beingDestroyed=true;
this.destroyDescendants(_15);
this.destroy(_15);
},destroy:function(_16){
this._beingDestroyed=true;
this.uninitialize();
var d=dojo,dfe=d.forEach,dun=d.unsubscribe;
dfe(this._connects,function(_17){
dfe(_17,d.disconnect);
});
dfe(this._subscribes,function(_18){
dun(_18);
});
dfe(this._supportingWidgets||[],function(w){
if(w.destroyRecursive){
w.destroyRecursive();
}else{
if(w.destroy){
w.destroy();
}
}
});
this.destroyRendering(_16);
dijit.registry.remove(this.id);
this._destroyed=true;
},destroyRendering:function(_19){
if(this.bgIframe){
this.bgIframe.destroy(_19);
delete this.bgIframe;
}
if(this.domNode){
if(_19){
dojo.removeAttr(this.domNode,"widgetId");
}else{
dojo.destroy(this.domNode);
}
delete this.domNode;
}
if(this.srcNodeRef){
if(!_19){
dojo.destroy(this.srcNodeRef);
}
delete this.srcNodeRef;
}
},destroyDescendants:function(_1a){
dojo.forEach(this.getChildren(),function(_1b){
if(_1b.destroyRecursive){
_1b.destroyRecursive(_1a);
}
});
},uninitialize:function(){
return false;
},onFocus:function(){
},onBlur:function(){
},_onFocus:function(e){
this.onFocus();
},_onBlur:function(){
this.onBlur();
},_onConnect:function(_1c){
if(_1c in this._deferredConnects){
var _1d=this[this._deferredConnects[_1c]||"domNode"];
this.connect(_1d,_1c.toLowerCase(),_1c);
delete this._deferredConnects[_1c];
}
},_setClassAttr:function(_1e){
var _1f=this[this.attributeMap["class"]||"domNode"];
dojo.removeClass(_1f,this["class"]);
this["class"]=_1e;
dojo.addClass(_1f,_1e);
},_setStyleAttr:function(_20){
var _21=this[this.attributeMap.style||"domNode"];
if(dojo.isObject(_20)){
dojo.style(_21,_20);
}else{
if(_21.style.cssText){
_21.style.cssText+="; "+_20;
}else{
_21.style.cssText=_20;
}
}
this.style=_20;
},setAttribute:function(_22,_23){
dojo.deprecated(this.declaredClass+"::setAttribute() is deprecated. Use attr() instead.","","2.0");
this.attr(_22,_23);
},_attrToDom:function(_24,_25){
var _26=this.attributeMap[_24];
dojo.forEach(dojo.isArray(_26)?_26:[_26],function(_27){
var _28=this[_27.node||_27||"domNode"];
var _29=_27.type||"attribute";
switch(_29){
case "attribute":
if(dojo.isFunction(_25)){
_25=dojo.hitch(this,_25);
}
var _2a=_27.attribute?_27.attribute:(/^on[A-Z][a-zA-Z]*$/.test(_24)?_24.toLowerCase():_24);
dojo.attr(_28,_2a,_25);
break;
case "innerHTML":
_28.innerHTML=_25;
break;
case "class":
dojo.removeClass(_28,this[_24]);
dojo.addClass(_28,_25);
break;
}
},this);
this[_24]=_25;
},attr:function(_2b,_2c){
var _2d=arguments.length;
if(_2d==1&&!dojo.isString(_2b)){
for(var x in _2b){
this.attr(x,_2b[x]);
}
return this;
}
var _2e=this._getAttrNames(_2b);
if(_2d>=2){
if(this[_2e.s]){
_2d=dojo._toArray(arguments,1);
return this[_2e.s].apply(this,_2d)||this;
}else{
if(_2b in this.attributeMap){
this._attrToDom(_2b,_2c);
}
this[_2b]=_2c;
}
return this;
}else{
return this[_2e.g]?this[_2e.g]():this[_2b];
}
},_attrPairNames:{},_getAttrNames:function(_2f){
var apn=this._attrPairNames;
if(apn[_2f]){
return apn[_2f];
}
var uc=_2f.charAt(0).toUpperCase()+_2f.substr(1);
return (apn[_2f]={n:_2f+"Node",s:"_set"+uc+"Attr",g:"_get"+uc+"Attr"});
},toString:function(){
return "[Widget "+this.declaredClass+", "+(this.id||"NO ID")+"]";
},getDescendants:function(){
return this.containerNode?dojo.query("[widgetId]",this.containerNode).map(dijit.byNode):[];
},getChildren:function(){
return this.containerNode?dijit.findWidgets(this.containerNode):[];
},nodesWithKeyClick:["input","button"],connect:function(obj,_30,_31){
var d=dojo,dc=d._connect,_32=[];
if(_30=="ondijitclick"){
if(!this.nodesWithKeyClick[obj.tagName.toLowerCase()]){
var m=d.hitch(this,_31);
_32.push(dc(obj,"onkeydown",this,function(e){
if((e.keyCode==d.keys.ENTER||e.keyCode==d.keys.SPACE)&&!e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey){
dijit._lastKeyDownNode=e.target;
d.stopEvent(e);
}
}),dc(obj,"onkeyup",this,function(e){
if((e.keyCode==d.keys.ENTER||e.keyCode==d.keys.SPACE)&&e.target===dijit._lastKeyDownNode&&!e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey){
dijit._lastKeyDownNode=null;
return m(e);
}
}));
}
_30="onclick";
}
_32.push(dc(obj,_30,this,_31));
this._connects.push(_32);
return _32;
},disconnect:function(_33){
for(var i=0;i<this._connects.length;i++){
if(this._connects[i]==_33){
dojo.forEach(_33,dojo.disconnect);
this._connects.splice(i,1);
return;
}
}
},subscribe:function(_34,_35){
var d=dojo,_36=d.subscribe(_34,this,_35);
this._subscribes.push(_36);
return _36;
},unsubscribe:function(_37){
for(var i=0;i<this._subscribes.length;i++){
if(this._subscribes[i]==_37){
dojo.unsubscribe(_37);
this._subscribes.splice(i,1);
return;
}
}
},isLeftToRight:function(){
return dojo._isBodyLtr();
},isFocusable:function(){
return this.focus&&(dojo.style(this.domNode,"display")!="none");
},placeAt:function(_38,_39){
if(_38.declaredClass&&_38.addChild){
_38.addChild(this,_39);
}else{
dojo.place(this.domNode,_38,_39);
}
return this;
},_onShow:function(){
this.onShow();
},onShow:function(){
},onHide:function(){
}});
})();
}
